//package com.pengzy.core.gateway_security;
//
//import com.pengzy.comment.web.redis.RedisCache;
//import com.pengzy.comment.web.result.ReactiveRequestContextHolder;
//import lombok.Data;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.server.reactive.ServerHttpRequest;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.server.ServerWebExchange;
//import org.springframework.web.server.WebFilter;
//import org.springframework.web.server.WebFilterChain;
//import reactor.core.publisher.Mono;
//import reactor.util.context.Context;
//
//import javax.annotation.Resource;
//import java.util.function.BiConsumer;
//
///**
// * @author xiaozhi 2023/7/19
// */
//
//@Component
//@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
//@Slf4j
//public class ReactiveRequestContextFilter implements WebFilter {
//
//
//    @Override
//    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
//        ReactiveRequestContextHolder.Infos.serverWebExchange=exchange;
//        return chain.filter(exchange)
//                .contextWrite(ctx->ctx.put(ReactiveRequestContextHolder.Info.CONTEXT_KEY, exchange));
//                //.contextWrite(Context.of(ReactiveRequestContextHolder.Info.CONTEXT_KEY, exchange));
////        return chain.filter(exchange)
////                .subscriberContext(ctx -> ctx.put(ReactiveRequestContextHolder.Info.CONTEXT_KEY, exchange));
//    }
//
//
//    @Data
//    static class MyContextContainer {
//        private Context context;
//    }
//
//    public static void main(String[] args) {
//        String key = "message";
//        Mono<String> r = Mono.just("Hello")
//                .flatMap(s -> Mono.deferContextual(ctx ->
//                        Mono.just(s + " " + ctx.get(key))))
//                .contextWrite(ctx -> ctx.put(key, "World"));
//
//
//    }
//}
